import matplotlib.pyplot as plt
from sklearn.datasets import load_boston
from sklearn import linear_model
import numpy as np

def plot(data2D, target1D, predict1D):
    plt.figure(figsize=(6, 3))
    plt.plot(data2D, target1D, 'y.', markersize=6, label='Samples')
    plt.plot(data2D, predict1D, 'k-', label='Prediction')
    plt.legend()
    plt.title('SciKit Ridge')
    plt.grid()
    plt.show()
    return

boston = load_boston()
X = boston.data[:,5]   # The fifth Attribute is the number of romos
X = X[:, np.newaxis]   # Regression fit needs a data matrix as argument
y = boston.target      # Regression fit methods need a target vector
ridge = linear_model.Ridge(alpha=0.3)
ridge.fit(X, y)
print("Slope: "+str(ridge.coef_)+", intercept:"+str(ridge.intercept_))
y_pred = ridge.predict(X)
plot(X, y, y_pred)
